package com.example.SBootDemo.Util.MAIL;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;
@Component
public class MailServiceImpl implements MailService{

	private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private JavaMailSender mailSender;

    @Value("${mail.fromMail.addr}")
    private String from;
    
    
	@Override
	public void sendSimpleMail(String to, String subject, String content) {
		// TODO Auto-generated method stub
		 SimpleMailMessage message = new SimpleMailMessage();
	        message.setFrom(from);
	        message.setTo(to);
	        message.setSubject(subject);
	        message.setText(content);

	        try {
	            mailSender.send(message);
	            logger.info("简单邮件已经发送。");
	        } catch (Exception e) {
	            logger.error("发送简单邮件时发生异常！", e);
	        }
	}

	@Override
	public void sendHtmlMail(String to, String subject, String content) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void sendAttachmentsMail(String to, String subject, String content, String filePath) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void sendInlineResourceMail(String to, String subject, String content, String rscPath, String rscId) {
		// TODO Auto-generated method stub
		
	}
	
}
